﻿using System;
using NUnit.Framework;

namespace Cuce.ReportingServices.UnitTests
{

    ///<summary>
    /// This class tests the Report Name class
    ///</summary>
    [TestFixture]
    public class ReportNameTest
    {

        ///<summary>
        ///</summary>
        [Test]
        public void ReportNameFormat()
        {
            var n = new ReportName();

            n.SetName("/CRR/test");

            Assert.IsTrue(n.Name == "test");
            Assert.IsTrue(n.Folder == "/CRR/");
            Assert.IsTrue(n.ToString() == "/CRR/test");
        }

        ///<summary>
        ///</summary>
        [Test]
        [ExpectedException(typeof(ArgumentException))]
        public void ReportNameFormat1()
        {
            var n = new ReportName();

            n.SetName("/CRR/test/");

            Assert.IsTrue(n.Name == "test");
            Assert.IsTrue(n.Folder == "/CRR/");
        }

        ///<summary>
        ///</summary>
        [Test]
        public void ReportNameFormat2()
        {
            var n = new ReportName();

            n.SetName("/CRR///test");

            Assert.IsTrue(n.Name == "test");
            Assert.IsTrue(n.Folder == "/CRR/");
        }

        ///<summary>
        ///</summary>
        [Test]
        [ExpectedException(typeof(ArgumentException))]
        public void ReportNameFormat3()
        {
            var n = new ReportName();

            n.SetName("CRR/test");

            Assert.IsTrue(n.Name == "test");
            Assert.IsTrue(n.Folder == "/CRR/");
        }

        ///<summary>
        ///</summary>
        [Test]
        public void ReportNameFormat4()
        {
            var n = new ReportName();

            n.SetName("/CRR/Test/test");

            Assert.IsTrue(n.Name == "test");
            Assert.IsTrue(n.Folder == "/CRR/Test/");
        }

        ///<summary>
        ///</summary>
        [Test]
        public void ReportNameFormat5()
        {
            var n = new ReportName();

            n.SetName("test","/CRR/Test/" );

            Assert.IsTrue(n.Name == "test");
            Assert.IsTrue(n.Folder == "/CRR/Test/");
        }

        ///<summary>
        ///</summary>
        [Test]
        [ExpectedException(typeof(ArgumentException))]
        public void ReportNameFormat15()
        {
            var n = new ReportName();

            n.SetName("", "/CRR/Test/");

            Assert.IsTrue(n.Name == "");
            Assert.IsTrue(n.Folder == "/CRR/Test/");
        }


        ///<summary>
        ///</summary>
        [Test]
        public void ReportNameFormat25()
        {
            var n = new ReportName();

            n.SetName("/asdfasd");

            Assert.IsTrue(n.Name == "asdfasd");
            Assert.IsTrue(n.Folder == "/");
           
        }

        ///<summary>
        ///</summary>
        [Test]
        [ExpectedException(typeof(ArgumentException))]
        public void ReportNameFormatNoPathNoFile()
        {
            var n = new ReportName();

            n.SetName("/");

            Assert.IsTrue(n.Name == "");
            Assert.IsTrue(n.Folder == "/");

        }

        ///<summary>
        ///</summary>
        [Test]
        [ExpectedException(typeof(ArgumentException))]
        public void ReportNameFormat24()
        {
            var n = new ReportName();

            n.SetName("");

            Assert.IsTrue(n.Name == "");

        }


        ///<summary>
        ///</summary>
        [Test]
        [ExpectedException(typeof(ArgumentException))]
        public void ReportNameFormat35()
        {
            var n = new ReportName();

            n.SetName("ddd", "");

            Assert.IsTrue(n.Name == "ddd");
            Assert.IsTrue(n.Folder == "");
        }

        ///<summary>
        ///</summary>
        [Test]
        [ExpectedException(typeof(ArgumentException))]
        public void ReportNameFormat6()
        {
            var n = new ReportName();

            n.SetName("test", "/CRR/Test");

            Assert.IsTrue(n.Name == "test");
            Assert.IsTrue(n.Folder == "/CRR/Test/");
        }

        ///<summary>
        ///</summary>
        [Test]
        [ExpectedException(typeof(ArgumentException))]
        public void ReportNameFormat7()
        {
            var n = new ReportName();

            n.SetName("test", "CRR/Test");

            Assert.IsTrue(n.Name == "test");
            Assert.IsTrue(n.Folder == "/CRR/Test/");
        }
    }
}
